package com.hx.net.a;


import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author jxlgcmh
 * @create 2019-05-10 16:01
 */
public class TCPServer {
    public static void main(String[] args) throws IOException {
        ServerSocket socket = new ServerSocket(8888);

        Socket accept = socket.accept();

        InputStream in = accept.getInputStream();

        ByteOutputStream stream = new ByteOutputStream();
        int len;
        byte buf[] = new byte[1024];
        while ((len = in.read(buf)) != -1) {
			/*String str = new String(buf, 0, len);
			System.out.println(str);*/
            stream.write(buf, 0, len);
        }


        System.out.println(stream.toString());


    }
}
